<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@include file="/jsp/commons/header.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

    <title>销售分析系统</title>
    <%@ include file="/jsp/commons/meta.jsp"%>
    <script type="text/javascript">
        $(function(){
            $("#login_form").validate({
                 rules:{
                	  sid:{
                          required:true,
                          remote:{
                              type:"POST",
                              url:"${ctx}/role/validateroleSid.htm",
                              data:{
                                  sid:function(){
                                  return $("#txtsid").val();
                                    }
                                }
                            }
                        },
                    },
                 messages:{
                      sid:{
                          required:"请输入",
                          remote:"id已经存在"
                        },
                    },
                 submitHandler: function(form) {
                      $.ajax({
                          type:"POST",  
                          url: "${ctx}/role/addRole.htm",
                          data: {
                              sid:$("#txtsid").val(),
                              roleName:$("#txtrole_name").val(),
                              comments:$("#txtrole_comments").val()
                              },
                          success: function(result){
                              $("#status").html("添加成功，正在跳转...");
                              window.location.href="${ctx}/role/FindRoleList.htm";
                            }
                         });
                    }
             });
         });
     </script>
</head>
<body>
    <form action="${ctx}/role/addRole.htm" method="POST" id="login_form">
        <table cellpadding="0" cellspacing="0">
            <tbody align="center">
                <tr>
                    <td align="center" colspan="2">
                    <div id="status"></div>
                      <h3>权限添加</h3>
                    </td>
                </tr>
                <tr>
                    <td align="right"><div id="sidd">ID：</div></td>
                    <td align="left"><input type="text" name="sid"
                      id="txtsid" /></td>
                </tr>
                <tr>
                    <td align="right"><div id="roleNamed">角色名：</div></td>
                    <td align="left"><input type="text" name="roleName"
                      id="txtrole_name"/></td>
                </tr>
                <tr>
                    <td align="right"><div id="commentsd">权限：</div></td>
                    <td align="left"><input type="text" name="comments"
                      id="txtrole_comments"/></td>
                </tr>
                <tr>
                    <td></td>
                    <td align="left" colspan="2"><input type="submit"
                      id="submitBtn" value="提交" class="login-btn" /></td>
                </tr>
            </tbody>
        </table>
    </form>
</body>
